<?php

namespace App\Widget;

class Manager
{
    private static $_instance = null;

    private $_widgets;

    protected function __construct(){}

    public static function getInstance()
    {
        if (!self::$_instance instanceof App\Widget\Manager) {
            self::$_instance = new self();
        }

        return self::$_instance;
    }

    public function registry($widget)
    {
        if (is_object($widget)) {
            //App\Widget
            $this->_widgets[$widget->getName()] = $widget;
        } elseif (is_string($widget) && $this->_widgets[$widget]) {
            return $this->_widgets[$widget];
        }
    }
}